#include<stdio.h>
#include<map>
using namespace std;
const int mod=998244353,maxn=25,maxs=1<<15,phi=mod-1,inv2=(mod+1)/2;
int k,a,b,srfl,srt;
long long n;
long long p[maxn],mul[maxs];
map<long long,int>mp;
int ksm(int a,long long b){
	b=(b%phi+phi)%phi;
	int res=1;
	while(b){
		if(b&1)
			res=1ll*res*a%mod;
		a=1ll*a*a%mod,b>>=1;
	}
	return res;
}
long long gcd(long long a,long long b){
	return b==0? a:gcd(b,a%b);
}
int Rot(long long d){
	long long orbv=d,orbe=(n-1)/2%phi*(d%phi)%phi;
	if(n%2==0)
		orbe=(orbe+gcd(d,n/2))%phi;
	return 1ll*ksm(a,orbv)*ksm(b,orbe)%mod;
}
int Refl(long long d,int o){
	long long orbv=d/2+(o|(d&1)),orbe=(n-1)/2%phi*((d+1)/2%phi)%phi;
	if(d%2==0)
		orbe+=(n/2-(o|(d&1)))/2;
	if(n%2==0){
		long long g=gcd(d,n/2);
		orbe+=g/2+(o|(g&1));
	}
	return 1ll*ksm(a,orbv)*ksm(b,orbe)%mod;
}
int main(){
	freopen("clown.in","r",stdin);
	freopen("clown.out","w",stdout);
	scanf("%d",&k),n=1;
	for(int i=1,x;i<=k;i++)	
		scanf("%d",&x),mp[x]=1,n*=x;
	scanf("%d%d",&a,&b),k=0;
	for(map<long long,int>::iterator it=mp.begin();it!=mp.end();it++)
		p[++k]=it->first;
	mul[0]=n;
	for(int i=0;i<(1<<k);i++){
		if(i>0){
			int l=(i&-i);
			mul[i]=mul[i^l]/p[__builtin_ctz(l)+1];
		}
		int coef=__builtin_parity(i)? (mod-1):1;
		long long d=mul[i];
		srt=(srt+1ll*coef*Rot(d))%mod;
		srfl=(srfl+1ll*coef*(Refl(d,0)+Refl(d,1)))%mod;
	}
	printf("%d\n",(srt+1ll*(mod-n%mod)*inv2%mod*srfl)%mod);
	return 0;
}
